﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRStatAndmeteKanneResponse", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRStatAndmeteKanneResponse))]
    public class RRStatAndmeteKanneResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRStatAndmeteKanneResponse clazz;
        
        public RRStatAndmeteKanneResponseSerializer(IRRStatAndmeteKanneResponse clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("vastus");
            if (clazz.Vastus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vastus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vastus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="vastus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRStatAndmeteKanneResponse>vastus");
                }
                clazz.Vastus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vastus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRStatAndmeteKanneResponse>vastus", Reader.LocalName);
            }
        }
    }
}
